#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1, cont = 1; i < s.size(); i++) {
      if (s[i - 1] == s[i]) {
        cont++;
      } else {
        if (cont & 1) {
          s[i] = s[i - 1];
          i++;
          ans++;
        }
        cont = 1;
      }
    }
    cout << ans << endl;
  }
}
